package com.smartleanx.module.hrm.framework.config;

import com.smartleanx.framework.datapermission.core.rule.dept.DeptDataPermissionRuleCustomizer;
import com.smartleanx.module.hrm.dal.dataobject.dingDing.DingConfirmation;
import com.smartleanx.module.hrm.dal.dataobject.employee.EmployeeDO;
import com.smartleanx.module.hrm.dal.dataobject.esign.ElecCorpDept;
import com.smartleanx.module.hrm.dal.dataobject.esign.HrmETempDept;
import com.smartleanx.module.hrm.dal.dataobject.payroll.PayrollDetailDO;
import com.smartleanx.module.hrm.dal.dataobject.payrollapproverecord.PayrollApproveRecordDO;
import com.smartleanx.module.hrm.dal.dataobject.risk.RiskDO;
import com.smartleanx.module.hrm.dal.dataobject.salary.HrmSalaryRecord;
import com.smartleanx.module.hrm.service.esign.temp.po.HrmEContractArchiving;
import com.smartleanx.module.hrm.service.esign.temp.po.HrmEContractTask;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 数据权限配置
 *
 * @author tengcj
 * @since 2024/5/24
 */
@Configuration(proxyBeanMethods = false)
public class HrmDataPermissionConfiguration {

    @Bean
    public DeptDataPermissionRuleCustomizer hrmDeptDataPermissionRuleCustomizer() {
        return rule -> {
            // 基于部门的数据权限 WHERE dept_id = ?
            rule.addDeptColumn(EmployeeDO.class);
            rule.addDeptColumn(PayrollDetailDO.class);
            rule.addDeptColumn(PayrollApproveRecordDO.class);
            rule.addDeptColumn(DingConfirmation.class);
            rule.addDeptColumn(RiskDO.class);
            rule.addDeptColumn(HrmSalaryRecord.class);
            rule.addDeptColumn(ElecCorpDept.class);
            rule.addDeptColumn(HrmETempDept.class);
            rule.addDeptColumn(HrmEContractTask.class);
            rule.addDeptColumn(HrmEContractArchiving.class);
            // 基于用户的数据权限 WHERE user_id = ?
            rule.addUserColumn(EmployeeDO.class);
            rule.addUserColumn(PayrollDetailDO.class);
            rule.addUserColumn(PayrollApproveRecordDO.class);
            rule.addUserColumn(HrmSalaryRecord.class);
            rule.addUserColumn(DingConfirmation.class);
            rule.addUserColumn(HrmEContractTask.class);
            rule.addUserColumn(HrmEContractArchiving.class);
        };
    }
}
